<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<!DOCTYPE html>
<html lang="zh-cmn-Hans">
<head>
<meta charset="UTF-8">
<link rel="shortcut icon" href="favicon.ico">
<link rel="stylesheet" href="css/iconfont.css">
<link rel="stylesheet" href="css/global.css">
<link rel="stylesheet" href="css/bootstrap.min.css">
<link rel="stylesheet" href="css/bootstrap-theme.min.css">
<link rel="stylesheet" href="css/swiper.min.css">
<link rel="stylesheet" href="css/styles.css">
<script src="js/jquery.1.12.4.min.js" charset="UTF-8"></script>
<script src="js/bootstrap.min.js" charset="UTF-8"></script>
<script src="js/swiper.min.js" charset="UTF-8"></script>
<script src="js/global.js" charset="UTF-8"></script>
<script src="js/jquery.DJMask.2.1.1.js" charset="UTF-8"></script>
<title>确认支付页面</title>
</head>
<body>
	<!-- 引入个人中心头部 -->
	<jsp:include page="user-header.jsp"></jsp:include>

	<div class="content clearfix bgf5">
		<section class="user-center inner clearfix">
			<div class="user-content__box clearfix bgf">
				<div class="title">购物车-确认支付</div>
				<div class="shop-title">选择收货地址</div>
				<form action="" class="shopcart-form__box">
					<!-- 收货地址 -->
					<div class="addr-radio">
						<c:forEach items="${shou }" var="shou">
							<div class="">

								<c:if test="${shou.idDefault=='是' }">
									<input name="xuandizhi" value="${shou.addId }"
										autocomplete="off" type="radio" checked />
										${shou.province } ${shou.city } ${shou.region } ${shou.fullAddress }（${shou.getName }收）${shou.getTel }
										&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="" class="edit"
										style="color: #b31e22">默认地址</a>
										&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="udai_address.jsp"
										class="edit">修改地址</a>
								</c:if>

								<c:if test="${shou.idDefault!='是' }">
									<input name="xuandizhi" value="${shou.addId }"
										autocomplete="off" type="radio" />
									    ${shou.province } ${shou.city } ${shou.region } ${shou.fullAddress }（${shou.getName }收） ${shou.getTel }
									    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href=""
										onclick="updDefault(this)" data-id="${shou.addId }"
										class="edit" style="color: #b31e22">设置为默认</a>
									    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="udai_address.jsp"
										class="edit">修改地址</a>
								</c:if>
							</div>
						</c:forEach>
						<div class="add_addr" style="padding-left: 0px">
							<a href="udai_address.jsp">添加新地址</a>
						</div>
					</div>
					<script type="text/javascript">
						//设置地址为默认
						function updDefault(obj) {
							var id = $(obj).data("id");
							//请求服务器
							$.post("updAddDefault", {
								"addId" : id
							}, function(res) {
								alert("设置成功");
								window.location.reload();
							}, "json")
						}
					</script>
					<!-- 选中的商品 -->
					<div class="shop-title">确认订单</div>
					<input type="hidden" name="ids" id="ids" value="${ids }" />
					<div class="shop-order__detail">
						<table class="table">
							<thead>
								<tr>
									<th width="120"></th>
									<th width="300">商品信息</th>
									<th width="150">单价</th>
									<th width="200">数量</th>
									<th width="200">运费</th>
									<th width="80">总价</th>
								</tr>
							</thead>
							<tbody>
								<!-- 展示商品信息 -->
								<c:if test="${getGouCart !=null }">
									<c:forEach items="${getGouCart }" var="getGouCart">
										<tr>
											<th scope="row"><a
												href="getProTuiTypeId?proId=${getGouCart.proId }">
													<div class="img">
														<img src="../admin/showPic/${getGouCart.proUrl }" alt=""
															class="cover">
													</div>
											</a></th>
											<td>
												<div class="name ep3">${getGouCart.proName }</div>
												<div class="type c9">品牌：${getGouCart.brand }
													材质：${getGouCart.material }</div>
											</td>
											<td>¥ ${getGouCart.currentPrice }</td>
											<td>${getGouCart.pnum }</td>
											<td>¥0.0</td>
											<td>¥ ${getGouCart.currentPrice*getGouCart.pnum }</td>
										</tr>
									</c:forEach>
								</c:if>
								<c:if test="${getGouCart ==null }">
									<tr>
										<th scope="row"><a
											href="getProTuiTypeId?proId=${proProId.proId }">
												<div class="img">
													<img src="../admin/showPic/${proProId.proUrl }" alt=""
														class="cover">
												</div>
										</a></th>
										<td>
											<div class="name ep3">${proProId.proName }</div>
											<div class="type c9">品牌：${proProId.brand }
												材质：${proProId.material }</div>
										</td>
										<td>¥ ${proProId.currentPrice }</td>
										<td>${proNum }</td>
										<td>¥0.0</td>
										<td>¥ ${sum }</td>
									</tr>
								</c:if>

							</tbody>
						</table>
					</div>
					<div class="shop-cart__info clearfix">
						<div class="pull-left text-left">
							<!-- <div class="info-line text-nowrap">
								购买时间：<span class="c6">2017年09月14日 17:31:05</span>
							</div> -->
							<div class="info-line text-nowrap">
								交易类型：<span class="c6">担保交易</span>
							</div>
							<!-- <div class="info-line text-nowrap">
								交易号：<span class="c6">1001001830267490496</span>
							</div> -->
						</div>
						<div class="pull-right text-right">
							<div class="info-line">
								运费：<span class="c6">¥0.00</span>
							</div>
							<div class="info-line">
								合计：<b class="fz18 cr" id="sum">¥${sum } </b>
							</div>
						</div>
					</div>
					<div class="shop-title">确认订单</div>
					<div class="pay-mode__box">
						<div class="radio-line radio-box">
							<label class="radio-label ep"> <input name="pay-mode"
								value="2" autocomplete="off" type="radio"><i
								class="iconfont icon-radio"></i> <img
								src="images/icons/alipay.png" alt="支付宝支付">
							</label>
							<div class="pay-value">
								支付<b class="fz16 cr">${sum }</b>元
							</div>
						</div>
						<div class="radio-line radio-box">
							<label class="radio-label ep"> <input name="pay-mode"
								value="3" autocomplete="off" type="radio"><i
								class="iconfont icon-radio"></i> <img
								src="images/icons/paywechat.png" alt="微信支付">
							</label>
							<div class="pay-value">
								支付<b class="fz16 cr">${sum }</b>元
							</div>
						</div>
					</div>
					<div class="user-form-group shopcart-submit">
						<button type="button" class="btn" onclick="tiJiao()">继续支付</button>
					</div>
					<script>
						//确认订单，地址id，购物车id
						function tiJiao() {
							//被选中地址id
							var addreddId = $('input[name="xuandizhi"]:checked')
									.val();
							console.log(addreddId);
							//选中购物车id
							var ids = $("#ids").val();
							console.log(ids);
							//商品付款价格
							var sum=${sum };
							console.log(sum);
                            if(ids!=null && ids!=''){
                            	$.post("shengChengDingDan", {
    								"addId" : addreddId,
    								"ids" : ids,
    								"sum":sum
    							}, function(res) {
    								if (res.code == 0) {
    									//alert("交易成功");
    									window.location.href = "getOderList"
    								}
    							}, "json");
                            }else{
                            	$.post("shengChengDanDingDan", {
    								"addId" : addreddId,
    								"sum":sum
    							}, function(res) {
    								if (res.code == 0) {
    									//alert("交易成功");
    									window.location.href = "getOderList"
    								}
    							}, "json");
                            }
							
						}
					</script>
				</form>
			</div>
		</section>
	</div>
	<!-- 引入右侧菜单 -->
	<jsp:include page="right-nav.jsp"></jsp:include>
	<!-- 底部信息 -->
	<!-- 引入脚部 -->
	<jsp:include page="footer.jsp"></jsp:include>
</body>
</html>